'''
Description: 
Author: Zilu
Date: 2021-11-17 19:15:19
Version: 
LastEditTime: 2021-11-17 19:32:30
LastEditors: Zilu
'''

# MySQL是Web世界中使用最广泛的数据库服务器。
# SQLite的特点是轻量级、可嵌入，但不能承受高并发访问，适合桌面和移动应用。
# 而MySQL是为服务器端设计的数据库，能承受高并发访问，同时占用的内存也远远大于SQLite。
import mysql.connector

conn = mysql.connector.connect(user='root', password='159875321.0@As', database='test')
cursor = conn.cursor()

cursor.execute(r'select * from students')
cursor.fetchall()
# MySQL的SQL占位符是%s
cursor.execute(r'insert into students (class_id, name, gender, score) values (%d, "%s", "%s", %d)' % (2, 'jinx', 'F', 67))
cursor.rowcount
cursor.close()
conn.commit()
conn.close()

conn = mysql.connector.connect(user='root', password='159875321.0@As', database='test')
cursor = conn.cursor()
cursor.execute(r'select name from students where score<70')
cursor.fetchall()
cursor.close()
conn.commit()
conn.close()




